﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json.Linq;
using SysFrame.BP;
using SysFrame.Message;

namespace AppServer.Controllers.System
{
    [Route("api/[controller]")]
    [ApiController]
    public class System16Controller : ControllerBase
    {   
        // 日志
        // POST: api/System7
        [HttpPost]
        public ActionResult<string> Post([FromBody] dynamic data)
        {
            string jsTimeStamp = data.jsTimeStamp;
            string Action = data.Action == null ? "Get" : data.Action;
            string rtstr = "";
            //得到列表
            if (Action == "Get")
            {
                rtstr = Get(data);
            }
            return rtstr;
        }
        /// <summary>
        /// 得到日志列表
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public string Get(dynamic data)
        {
            JObject postdata = JObject.FromObject(data.data);
            string search = postdata["search"].ToString();
            MsQuery msq = new MsQuery();
            //条件
            if (!string.IsNullOrEmpty(search))
            {
                msq.strquery += " and (System_16_20 like '%" + search + "%' ";
                msq.strquery += " or System_16_30 like '%" + search + "%' ";
                msq.strquery += " or s4_1.SYSTEM_4_40 like '%" + search + "%' ";
                msq.strquery += " or System_16_50 like '%" + search + "%' ";
                msq.strquery += " or System_16_60 like '%" + search + "%' ";
                msq.strquery += " or System_16_70 like '%" + search + "%' ";
                msq.strquery += " or System_16_80 like '%" + search + "%' ";
                msq.strquery += " or System_16_90 like '%" + search + "%' ";
                msq.strquery += " or System_16_100 like '%" + search + "%' ";
                msq.strquery += " or System_16_110 like '%" + search + "%' ";
                msq.strquery += " or System_16_120 like '%" + search + "%' ";
                msq.strquery += " or System_16_130 like '%" + search + "%' ";
                msq.strquery += ") ";
            }
            msq.strorder = "System_16_80 desc";
            DataTable dt = ((DataSet)(new BLLsystem_16().Getsystem_16ByQuery(msq).data)).Tables[0];


            return JArray.FromObject(dt).ToString();
        }
    }
}